package org.example.objevent.process.login;

import org.example.objevent.process.login.data.LoginData;
import org.example.objevent.process.login.data.LoginResult;
import org.example.objevent.process.login.service.LoginService;
import org.example.objevent.process.login.service.SmsService;
import org.example.objevent.process.login.service.UserService;

// process: login
public class ValidateLoginPhase {
    // event: validate_login
    // actor: validate_login

    private SmsService smsService;
    private LoginService loginService;
    private UserService userService;

    public boolean execute(LoginData loginData){

        // 静态检查
        //    长度检查，规则检查等

        // 业务检查
        //   手机验证码检查等
        //   用户名是否已被注册等

        if(smsService.verify(loginData.getUsername(), "")){
            // false,
            // message
            return false;

        }

        loginService.saveLogin(loginData);

        LoginResult loginResult = userService.getLoginResult(loginData);

        return true;

    }

}
